#include "hurtground.h"
#include<gamedefine.h>
hurtground::hurtground() {
    if(hurtgroundpixmap!=nullptr){
        delete[]hurtgroundpixmap;
    }
}

hurtground::hurtground(qreal x, qreal y)
{
    setPos(x,y);
    hurtgroundpixmap=new QPixmap (":/gameresource/spike.png");
    setPixmap(*hurtgroundpixmap);
    setData(iscollision,true);
    setData(ObjectType,3);
}

QPixmap hurtground::flipVertical()
{  if(hurtgroundpixmap==nullptr){return QPixmap();}
    QImage image = hurtgroundpixmap->toImage();

    QTransform transform;
    transform.scale(1, -1);  // 垂直翻转
    transform.translate(0, -image.height()); // 向下平移修正位置

    QImage flippedImage = image.transformed(transform);
    return QPixmap::fromImage(flippedImage);

}
